package displayboardinfo.tests;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;

import displayboardinfo.entities.Admission;
import displayboardinfo.entities.Room;
import displayboardinfo.messages.ListRoomsRes;
import displayboardinfo.utils.Utils;

public class AdmissionsTest {
	
	
	public static void main(String[] args) throws ParseException {
		ClientConfig config = new DefaultClientConfig();
		Client client = Client.create(config);
		WebResource service = client.resource(UriBuilder.fromUri("http://localhost:8080/DisplayBoardInfoServer").build());
		
		ClientResponse res = service.path("rooms").path("list").type(MediaType.APPLICATION_XML).get(ClientResponse.class);
		Room room = res.getEntity(ListRoomsRes.class).getRooms().get(0);
		
		SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm");
		Date date = dateFormat.parse("08-05-2012 14:59");
		
		for (Admission a : Utils.listAdmissions(room)){
			System.out.println(a.isInDate(date));
		}
	}
	
	
}
